//
//  MCStoreMapView.swift
//  StoreManage
//
//  Created by MC on 2017/12/28.
//  Copyright © 2017年 MC. All rights reserved.
//

import UIKit

import MapKit

class MCStoreMapView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        
        backgroundColor = UIColor.MCGray_light

        
        self.addSubview(bgView)
        bgView.snp.remakeConstraints { (make) ->Void in
            make.edges.equalTo(self)
        }

        bgView.addSubview(mapView)
        mapView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(bgView)
            make.top.equalTo(bgView)
            make.size.equalTo(CGSize.init(width: MCScreenWidth, height: MCScreenWidth*0.8))
        }
        
        mapView.addSubview(locationImageView)
        locationImageView.snp.remakeConstraints { (make) ->Void in
            make.center.equalTo(mapView)
            make.size.equalTo(CGSize.init(width: 14, height: 17))
        }
        
        let showW = MCScreenWidth * 0.45
        let showH = showW * 10 / 17
        
        mapView.addSubview(showImageView)
        showImageView.snp.remakeConstraints { (make) ->Void in
            make.centerX.equalTo(bgView)
            make.bottom.equalTo(locationImageView.snp.top).offset(-10)
            make.size.equalTo(CGSize.init(width: showW, height: showH))
        }
        
        showImageView.addSubview(mapAddressImageView)
        mapAddressImageView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(showImageView).offset(10)
            make.centerY.equalTo(showImageView.snp.top).offset(showH / 3)
            make.size.equalTo(CGSize.init(width: 12, height: 14.4))
        }
        
        showImageView.addSubview(mapPhoneImageView)
        mapPhoneImageView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(showImageView).offset(10)
            make.centerY.equalTo(showImageView.snp.top).offset(showH * 2 / 3)
            make.size.equalTo(CGSize.init(width: 12, height: 12))
        }
        
        showImageView.addSubview(mapAddressLabel)
        mapAddressLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(mapAddressImageView.snp.right).offset(5)
            make.right.equalTo(showImageView).offset(-5)
            make.centerY.equalTo(mapAddressImageView)
            make.height.equalTo(30)
        }
        
        showImageView.addSubview(mapPhoneLabel)
        mapPhoneLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(mapPhoneImageView.snp.right).offset(7)
            make.right.equalTo(showImageView).offset(-5)
            make.height.equalTo(15)
            make.centerY.equalTo(mapPhoneImageView)
        }
        
        bgView.addSubview(grayView)
        grayView.snp.remakeConstraints { (make) ->Void in
            make.left.right.equalTo(bgView)
            make.height.equalTo(MCScreenWidth * 0.3)
            make.bottom.equalTo(self.bgView)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        return view
    }()
    
    lazy var mapView: MKMapView = {
        let view = MKMapView.init()
        view.mapType = MKMapType.standard
        view.isScrollEnabled = false
        view.isZoomEnabled = false
        return view
    }()
    
    lazy var showImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Store_addressBg")
        return imageView
    }()

    
    lazy var locationImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Store_location")
        return imageView
    }()
    
    lazy var mapAddressImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Store_location")
        return imageView
    }()
    
    lazy var mapPhoneImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Store_phone")
        return imageView
    }()
    
    lazy var mapPhoneLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(12)
        label.textColor = UIColor.black
        return label
    }()
    
    lazy var mapAddressLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(12)
        label.textColor = UIColor.black
        label.numberOfLines = 0
        return label
    }()
    
    lazy var grayView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()

}
